package com.etc.service.impl;

import com.etc.dao.ProductMapper;
import com.etc.entity.Product;
import com.etc.service.ProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    ProductMapper productMapper;

    @Override
    public List<Product> findAllProduct() {
        List<Product> list = productMapper.selectAllProduct();
        return list;
    }

    @Override
    public boolean delectThisProd(Long productId) {
        int i = productMapper.deleteByPrimaryKey(productId);
        return i>0?true:false;
    }

    /*分页查询*/
    @Override
    public PageInfo<Product> doFindAllByPage(Integer unm) {

        PageHelper.startPage(unm,8);

        List<Product> list = productMapper.selectAllProduct();

        PageInfo<Product> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
}
